True this frame if button b is pressed (the frame it went down). Add a player number from 1 to 4 to ask another controller: btn_pressed(BTN_A, 2). Without one it is player 1.
btn_pressed(b, player = 1) -> bool| Name | Type |
|---|---|
b | button |
player | int (can be left out; then it is 1) |
bool
True this frame if a given button is pressed.
True on exactly one frame: the frame a button first goes down. The right check for a one-shot action - firing a shot, opening a menu - that should not repeat every frame the button stays held.
Write a player number from 1 to 4 after the button to ask that player's controller: btn_pressed(BTN_A, 2). Leave it out and it is player 1, the same as writing 1. The number has to be written out in the call (not kept in a variable), and a console that has fewer controllers than that tells you so when you check the game: the Game Boy Advance has one, so only player 1 works there.
if (btn_pressed(BTN_A)) {
var pressed_a = true;
}Checks the A button's pressed state every frame and records it in a project-defined pressed_a variable.
The Game Boy Advance has one controller, so only player 1 can be asked here (written out or left out, it is the same call).